var express = require("../../../express/node_modules/express");
var router = express.Router();//导入route模块,自带的

var inform = require("./资源");
router.get("/api/products", (req, res) => {
    var arr = inform.searchGood(req.query.category, req.query.minvalue, req.query.maxvalue);
    if (arr == false) {
        res.status(404);//返回res
        res.send({ code: 404, mes: "不存在" })
        return 0;
    }
    res.send(arr);
});
router.post("/api/users", (req, res) => {
    var name, email, age;
    if (req.body == undefined) {
        name = req.query.name;
        email = req.query.email;
        age = req.query.age;
        res.send(inform.register(req.query.name, req.query.email, req.query.age))
    } else {
        name = req.body.name;
        email = req.body.email;
        age = req.body.age;
        inform.edit(req.body.name, req.body.email, req.body.age)
        res.send(inform.showlist());
    }


})
module.exports = router//导出模块,对象法,直接这样
